import { Prefab, resources } from "cc";
import { Ab_Hint_bA } from "./float.hint";

export enum Ab_EFloat_bA {
	Ab_HINT_bA,
	Ab_FRUIT_DIAMOND_bA,
	Ab_FRUIT_SPECIAL_bA,
}

const Ab_Config_bA = {
	[Ab_EFloat_bA.Ab_HINT_bA]: {
		component: Ab_Hint_bA,
		path: 'prefab/float/hint',
		script: './float.official.hint',
		prefab: null,
	},
	[Ab_EFloat_bA.Ab_FRUIT_DIAMOND_bA]: {
		component: Ab_Hint_bA,
		path: 'prefab/float/fruit-diamond',
		script: './float.fruit.diamond',
		prefab: null,
	},
	[Ab_EFloat_bA.Ab_FRUIT_SPECIAL_bA]: {
		component: Ab_Hint_bA,
		path: 'prefab/float/fruit-special',
		script: './float.fruit.special',
		prefab: null,
	},
}

export async function Ab_GetFloatPrefab_bA(p: Ab_EFloat_bA): Promise<Prefab> {
	let conf = Ab_Config_bA[p];
	if(!conf.prefab){
		conf.prefab = await abi.Ab_cc_bA.Ab_loadResAsync_bA(conf.path, Prefab, resources);
	}

	return conf.prefab;
}

export async function Ab_GetFloatComponent_bA<F extends Ab_EFloat_bA>(p: F): Promise<(typeof Ab_Config_bA)[F]['component']> {
	let conf = Ab_Config_bA[p];
	if(!conf.component){
		conf.component = await import(conf.script).then(m=>m.default);
	}

	return conf.component;
}

export type Ab_FloatCtor_bA<F extends Ab_EFloat_bA> = typeof Ab_Config_bA[F]['component'];

export type Ab_FloatIns_bA<F extends Ab_EFloat_bA> = InstanceType<Ab_FloatCtor_bA<F>>;
